package ar.edu.sovietrussia.customcomponents.maincomponentviews;

import org.apache.wicket.authroles.authorization.strategies.role.annotations.AuthorizeInstantiation;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.form.Button;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.panel.Panel;

import users.Person;
import ar.edu.sovietrussia.customcomponents.personconfig.PersonalUserConfiguration;

@AuthorizeInstantiation("USER")
public class MainUserComponent extends Panel {

    private static final long serialVersionUID = 5782642735520738464L;

    public MainUserComponent(final String id) {
        super(id);

        Person aModel = (Person) getSession().getAttribute("model");

        Form<String> form = new Form<String>("mainUserForm");

        form.add(new Label("userNameLabel", aModel.getUserAccount().getRole().toString() + ": " + aModel.getSurname()
                + "," + aModel.getName()));

        // Button to ReservationsList Window
        form.add(new Button("reservationsList_button") {
            private static final long serialVersionUID = 3610707962001534656L;

            @Override
            public void onSubmit() {
                // TODO: go to RESERVATIONS LIST
            }
        });
        // Button to ReservationsList Window
        form.add(new Button("records_button") {
            private static final long serialVersionUID = 5119888790644143879L;

            @Override
            public void onSubmit() {
                // TODO: go to RECORDS
            }
        });
        // Button to ReservationsList Window
        form.add(new Button("personalConfiguration_button") {
            private static final long serialVersionUID = -7180926749213514766L;

            @Override
            public void onSubmit() {
                MainUserComponent.this.replaceWith(new PersonalUserConfiguration(MainUserComponent.this.getId(),
                        MainUserComponent.class));
            }
        });
        add(form);
    }
}